package me.kagami.myjvm.jvm;

import me.kagami.myjvm.jvm.opcode.OpCodeInterface;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.LabelNode;

public class InstructionService {


    public static void executeFrame(Frame frame) {
        InsnList instructions = frame.getInstructions();
//        System.out.println("该帧有指令数：" + instructions.size());

        while (frame.next()) {
            int opcode = frame.getProgramCtr().getOpcode();
            OpCodeInterface opCodeInterface = OpCodeService.CODE_MAP.get(opcode);
            if (opCodeInterface == null) {
                System.out.println("异常，指令没有实现类" + opcode);
                return;
            }
            opCodeInterface.handle(frame);
        }
    }
}
